package cn.leyaber.hrm.service.impl;

import cn.leyaber.hrm.domain.Comment;
import cn.leyaber.hrm.mapper.CommentMapper;
import cn.leyaber.hrm.redusutils.constants.CommentConstant;
import cn.leyaber.hrm.service.ICommentService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ma.rui.kai
 * @since 2020-12-11
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
    @Autowired
    private  CommentMapper commentMapper;

    /**
     * 批量删除
     * @param ids
     */
    @Override
    public void batchDelete(List<Long> ids) {
        System.out.println(ids);
        commentMapper.batchDelete(ids);
    }

    @Override
    public void Modify_status(Comment comment) {
        if (comment.getStateJyan().equals(CommentConstant.COMMENT_DISABLE)&&
            comment.getStatePbi().equals(CommentConstant.COMMENT_DISABLE)){
            comment.setStatePbi(CommentConstant.COMMENT_ENABLE);
            comment.setStateJyan(CommentConstant.COMMENT_ENABLE);
            commentMapper.updateById(comment);
        }else {
            comment.setStatePbi(CommentConstant.COMMENT_ENABLE);
            comment.setStateJyan(CommentConstant.COMMENT_ENABLE);
            commentMapper.updateById(comment);
        }

    }
}
